n, q = map(int, input().split())
num = [0] + list(map(int, input().split()))
for i in range(q):
    k = list(map(int, input().split()))
    if len(k) == 3:
        a, b, c = k
        print(sum(num[b:c + 1]))
    else:
        a, b, c, d = k
        for i in range(b, c + 1):
            num[i] += d
n, q = map(int, input().split())
a = [0] + list(map(int, input().split()))
for i in range(q):
    lr = list(map(int, input().split()))
    if len(lr) == 3:
        m, l, r = lr
        print(sum(a[l:r + 1]))
    else:
        m, l, r, k = lr
        for i in range(l, r + 1):
            a[i] += k
